/*
 * @Description: 入口文件
 * @Author: zhihong deng
 * @Date: 2021-08-17 17:09:47
 * @LastEditors: zhihong deng
 * @LastEditTime: 2021-10-05 23:39:08
 */
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/lib/theme-chalk/index.css'
import request from './utils/request'
import storage from './utils/storage'
import api from './api'
import store from './store'

// console.log("环境变量：",import.meta.env);

const app = createApp(App);
// 自定义全局指令
app.directive('has', {
  beforeMount:function(el, binding) {
    // console.log(el, binding);
    // 获取按钮权限
    let actionList = storage.getItem("actionList")
    // console.log('获取按钮权限', actionList);
    let value = binding.value
    // 判断列表中是否有对应权限标识
    let hasPermission = actionList.includes(value)
    // 如果没有权限就将对应的按钮隐藏掉
    if (!hasPermission) {
      el.style = "display:none"
      setTimeout(() => {
        el.parentNode.removeChild(el)
      }, 0)
    }
  },
})
app.config.globalProperties.$request = request;
app.config.globalProperties.$api = api;
app.config.globalProperties.$storage = storage;

app.use(router).use(ElementPlus, {size: 'small'}).use(store).mount('#app')
